﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing.Design;
using System.Windows.Forms;

namespace ArgosDesktop.Design
{
	public class FolderPathEditor : UITypeEditor
	{

		public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, IServiceProvider provider, object value)
		{

			using (FolderBrowserDialog dlg = new FolderBrowserDialog())
			{
				dlg.Description = "Select Folder";
				dlg.SelectedPath = value as string;
				dlg.ShowNewFolderButton = true;

				if (dlg.ShowDialog() == DialogResult.OK)
				{
					return dlg.SelectedPath;
				}

			}
			return value;
		}

		public override UITypeEditorEditStyle GetEditStyle(System.ComponentModel.ITypeDescriptorContext context)
		{
			return UITypeEditorEditStyle.Modal;
		}

	}
}
